﻿using Microsoft.Practices.SharePoint.Common.Configuration;
using Microsoft.SharePoint;
using System.Collections.Generic;
using System.Collections;
using System.Linq;

namespace SharePoint.Contrib.ApplicationSettings
{
    internal class SPSiteCollectionSettingsCollection : SPSiteSettingsCollection
    {

        public SPSiteCollectionSettingsCollection(IPropertyBag properties, SPSite sitecollection)
            :base(properties, sitecollection.RootWeb)
        {
        }

        protected override Dictionary<string, string> FindAllProperties()
        {
            return (from DictionaryEntry property in site.AllProperties
                    where property.Key.ToString().StartsWith(SPG.PNPNamespacePrefix) &&
                          property.Key.ToString().EndsWith(SPG.PNPSiteCollectionNamespaceSuffix)
                    select property)
            .ToDictionary(kvp => kvp.Key.ToString(), kvp => kvp.Value.ToString());
        }
    }
}
